<template>
	<view>
		{{name}}
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:"缓存无数据"
			}
		},
		onLoad() {
			console.log("页面正在加载中")
			uni.request({
				url: "https://www.baidu.com?name="+this.name,
				method: "GET",
				success:(res)=>{
					console.log("百度访问成功",res)
				},
				fail: (error) => {
					console.log("百度访问失败",error)
				}
			})
			//读取缓存判断是否存在 给name赋值
			let name=uni.getStorageSync("name");
			if(name){
				console.log("读取到缓存")
				this.name=name
			}
		},
		methods: {
			
		}
	}
</script>

<style>

</style>
